<template>
  <div class="about">
    <header>
      <div>
        <img src="../../public/titlet.png" alt="" />
      </div>
      <div>
        <input type="text" />
      </div>
      <div>
        <div>首页</div>
        <div>新手入门</div>
        <div>API</div>
        <div>关于</div>
        <div>注册</div>
        <div>登录</div>
      </div>
    </header>
    <section @scroll="onScroll">
      <div class="item_box_contn">
        <div>
          <van-tabs v-model="active">
            <van-tab title="全部">
              <div
                class="item_box"
                v-for="(item, index) in dotolist"
                :key="index"
              >
                <div>
                  <img :src="item.author.avatar_url" alt="" />
                </div>
                <div>
                  <span>{{ item.tab | valfilter }}</span>
                </div>
                <div>
                  <span>{{ item.title }}</span>
                  <span>{{ item.reply_count }}/{{ item.visit_count }}</span>
                </div>
              </div>
            </van-tab>
            <van-tab title="精华">内容 2</van-tab>
            <van-tab title="分享">内容 3</van-tab>
            <van-tab title="问答">内容 4</van-tab>
            <van-tab title="招聘">内容 5</van-tab>
            <van-tab title="客户测试">内容 6</van-tab>
          </van-tabs>
        </div>
      </div>
    </section>
    <footer>
      <div v-show="islog">
        <img src="../../public/9525ed4f1e541e9c669836fd0866f1ed.gif" alt="" />
      </div>
    </footer>
  </div>
</template>
<script>
export default {
  data() {
    return {
      active: 0,
      dotolist: [],
      islog: false,
    };
  },
  filters: {
    valfilter(val) {
      if (val == "ask") {
        return "精华";
      } else if (val == "share") {
        return "分享";
      } else if (val == "job") {
        return "招聘";
      } else if (val == "good") {
        return "客户测试";
      }
    },
  },
  mounted() {
    this.$axios.get("/list.json").then((res) => {
      console.log(res);
      this.dotolist = res.data.data;
      console.log(this.dotolist);
    });
  },
  methods: {
    onScroll(event) {
      var clientHenght = event.target.clientHeight;

      var scrollHeight = event.target.scrollHeight;

      var scrollTop = event.target.scrollTop;

      if (scrollHeight - scrollTop - clientHenght <= 1) {
        this.islog = true;
        setTimeout(() => {
          this.$axios.get("/list.json").then((res) => {
            res.data.data.forEach((item) => {
              this.dotolist.push(item);
            });
          });
          this.islog=false
        },3000);
      }
    },
  },
};
</script>
<style lang="scss" scoped>
header {
  width: 100vw;
  height: 20vh;
  background: rgb(68, 68, 68);
  div:nth-child(1) {
    width: 100%;
    img {
      width: 100%;
    }
  }
  div:nth-child(2) {
    width: 100%;
    input {
      width: 70%;
      height: 2rem;
      border: none;
      outline: none;
      border-radius: 1rem;
    }
  }
  div:nth-child(3) {
    width: 100%;
    height: 3rem;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    // height: ;
    > div {
      width: 2rem;
      font-size: 0.4rem;
      // display: flex;
      // justify-content: space-between;
      color: #FFF;
    }
  }
}
section {
  width: 100vw;
  height: 70vh;
    overflow: auto;

  background: rgb(196, 190, 190);
  img {
    width: 3rem;
  }
  .item_box_contn{
    width: 100%;
    height: 100%;

  }
  .item_box {
    width: 100%;
    display: flex;
    justify-content: space-around;
    div:nth-child(1) {
      width: 15%;
    }
    div:nth-child(2) {
      width: 15%;
    }
    div:nth-child(3) {
      width: 70%;
      span:ntk-child(1) {
        display: inline-block;
        overflow: hidden;
        // white-space: nowrap;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }
    }
  }
}
footer {
  width: 100vw;
  height: 10vh;
  background: rgb(184, 184, 184);
  img{
    width: 30vh;
    height: 10vh;
  }
}
</style>